
//import a.b.c.d.Person;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Reflect {
	public static void main(String args[]) throws Exception { 
		Class<?> c = null;
		try {
			c = Class.forName("a.b.c.d.Person");
		}catch (ClassNotFoundException e) {
			System.out.println(e);
		}

		Object p = null;
		
		try {
			p = c.newInstance();
		}catch (InstantiationException e1) {
			System.out.println(e1);
		}catch (IllegalAccessException e1) {
			System.out.println(e1);
		}

		Constructor<?> con = c.getConstructor(String.class);
		Object p2 = con.newInstance("weidongshan");

		Method set = c.getMethod("setName", String.class);
		set.invoke(p2,"123");
		set.invoke(p,"abc");

		Method get = c.getMethod("getName");
		System.out.println(get.invoke(p));
		System.out.println(get.invoke(p2));

	}

}













